#pragma comment(linker, "/STACK:10000000")
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <cstdio>
#include <cassert>
#include <string>
#include <cstring>
#define ldb long double
#define LL long long
#define fi first
#define se second
#define fill(a, c) memset(a, c, sizeof(a))
#define sqr(a) ((a) * (a))
#define nextLine() {int c = 0; while((c = getchar()) != 10 && c != EOF);}
#define getBit(mask, k) (((mask) / pw[k]) % pw[1])
#define setBit(mask, k, l) (((mask) / pw[k + 1] * pw[1] + (l)) * pw[k] + ((mask) % pw[k]))
#define debug(a) cerr << #a << " = " << a << " ";
#define debugl(a) cerr << #a << " = " << a << "\n";
const ldb LDINF = 9128739847123.00;
const ldb eps = 1e-9;
const int INF = 1 << 30;
const ldb pi = fabsl(atan2(0.0, -1.0));
using namespace std;

int n;
string s[1110], w;
char let;


void Load()
{
	cin >> n;
	int i;
	for (i = 0; i < n; i++)
	{
		cin >> s[i];
	}
	cin >> w;
	cin >> let;
	let = tolower(let);
}

int dp[1110], pr[1110];
bool tochange[310];

int f(int i)
{
	if (i == w.size())  return 0;
	if (dp[i] != -1) return dp[i];
	dp[i] = -2;
	if (tochange[i])
	{
		int from = 'a';
		if (w[i] >= 'A' && w[i] <= 'Z') from = 'A';
		for (int j = from; j < from + 26; j++)
		{
			if (tolower(j) == tolower(w[i])) continue;
			int t = (tolower(j) == let) ? 1 : 0;
			if (dp[i] < f(i + 1) + t)
			{
				dp[i] = f(i + 1) + t;
				pr[i] = j;
			}
		}
	}
	else
	{
		dp[i] = f(i + 1);
		pr[i] = w[i];
	}
	return dp[i];
}

void out(int i)
{
	if (i == w.size()) return;
	printf("%c", pr[i]);
	out(i + 1);
}



void Solve()
{
	memset(dp, -1, sizeof dp);
	string pp = w;
	for (int i = 0; i < w.size(); i++)
		pp[i] = tolower(pp[i]);

	for (int i = 0; i < n; i++)
	{	
		for (int j = 0; j < s[i].size(); j++)
			s[i][j] = tolower(s[i][j]);
		int t = 0;
		while ((t = pp.find(s[i], t)) != -1)
		{
			for (int j = 0; j < s[i].size(); j++)
				tochange[t + j] = true;
			t++;
		}
	}
	f(0);
	out(0);
}

#define file "a"
int main()
{
	#ifndef ONLINE_JUDGE
		freopen(file".in", "rt", stdin);
		freopen(file".out", "wt", stdout);
	#endif
	Load();
	Solve();
	return 0;
}
